﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" CodeFile="ProfileInfo.aspx.cs" Inherits="ProfileInfo" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="MainContent">
    <asp:Panel ID="Panel1" runat="server">
        <table style="text-align:center">
            <tr>
                <td colspan="2">
                    <asp:Label ID="Label1" runat="server" Text="My Details"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:UpdatePanel runat="server">
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="GridView2" EventName="SelectedIndexChanging" />
                        </Triggers>
                        <ContentTemplate>
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                AutoGenerateColumns="False" DataSourceID="FriendsDS" 
                                onrowdeleting="GridView1_RowDeleting" 
                                onselectedindexchanging="GridView1_SelectedIndexChanging" 
                                RowStyle-HorizontalAlign="Center"
                                CssClass="mGrid" 
                                PagerStyle-CssClass="pgr" 
                                AlternatingRowStyle-CssClass="alt">
                                <AlternatingRowStyle CssClass="alt" />
                                <Columns>
                                    <asp:CommandField SelectText="View Details" ShowSelectButton="True" />
                                    <asp:BoundField DataField="Username" HeaderText="Username" 
                                        SortExpression="Username" />
                                    <asp:CommandField DeleteText="Remove Friend" ShowDeleteButton="True" />
                                </Columns>
                                <PagerStyle CssClass="pgr" />
                                <RowStyle HorizontalAlign="Center" />
                            </asp:GridView>
                             <asp:ObjectDataSource ID="FriendsDS" runat="server" DeleteMethod="removeFriend" 
                                SelectMethod="getFriends" TypeName="ForumLibrary.Data.ForumWebManager" 
                                ondeleting="FriendsDS_Deleting" InsertMethod="addFriend" >
                                <DeleteParameters>
                                    <asp:Parameter Name="friendRemoving" Type="String" />
                                    <asp:Parameter Name="friendRemoved" Type="String" />
                                </DeleteParameters>
                                 <InsertParameters>
                                     <asp:Parameter Name="friendAdding" Type="String" />
                                     <asp:Parameter Name="friendAdded" Type="String" />
                                 </InsertParameters>
                                <SelectParameters>
                                    <asp:SessionParameter Name="username" SessionField="username" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
                <td align="center">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanging"/>
                        </Triggers>
                        <ContentTemplate>
                            <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
                                AutoGenerateRows="False" DataSourceID="FriendsDetailsDS" 
                                BorderStyle="Double" CssClass="mGrid" AlternatingRowStyle-CssClass="alt">
                                <Fields>
                                    <asp:BoundField DataField="Username" HeaderText="Username" 
                                        SortExpression="Username" />
                                    <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                                        SortExpression="FirstName" />
                                    <asp:BoundField DataField="LastName" HeaderText="LastName" 
                                        SortExpression="LastName" />
                                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                    <asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber" 
                                        SortExpression="PhoneNumber" />
                                    <asp:CheckBoxField DataField="Moderator" HeaderText="Moderator" 
                                        SortExpression="Moderator" />
                                    <asp:CheckBoxField DataField="LoggedIn" HeaderText="LoggedIn" 
                                        SortExpression="LoggedIn" />
                                </Fields>
                            </asp:DetailsView>
                            <asp:ObjectDataSource ID="FriendsDetailsDS" runat="server" SelectMethod="getUser" 
                                TypeName="ForumLibrary.Data.ForumWebManager" UpdateMethod="getUser">
                                <SelectParameters>
                                    <asp:Parameter Name="username" Type="String" />
                                </SelectParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="username" Type="String" />
                                </UpdateParameters>
                            </asp:ObjectDataSource>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server" HorizontalAlign="Center">
        <p>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Search for a friend:
            <asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" ></asp:TextBox>
            <asp:Button ID="SearchButton" runat="server" Text="Search" 
                onclick="SearchButton_Click" />
        </p>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="SearchButton" EventName="Click"/>
            </Triggers>
            <ContentTemplate>
                <asp:GridView ID="GridView2" runat="server" RowStyle-HorizontalAlign="Center" 
                    HorizontalAlign="Center" AutoGenerateColumns="False" 
                    DataSourceID="UsersDS" 
                    onselectedindexchanging="GridView2_SelectedIndexChanging"
                    CssClass="mGrid" AlternatingRowStyle-CssClass="alt">
                    <AlternatingRowStyle CssClass="alt" />
                    <Columns>
                        <asp:CommandField SelectText="Add To Friends" ShowSelectButton="True" />
                        <asp:BoundField DataField="Username" HeaderText="Username" 
                            SortExpression="Username" />
                        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                            SortExpression="FirstName" />
                        <asp:BoundField DataField="LastName" HeaderText="LastName" 
                            SortExpression="LastName" />
                        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                        <asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber" 
                            SortExpression="PhoneNumber" />
                        <asp:CheckBoxField DataField="Moderator" HeaderText="Moderator" 
                            SortExpression="Moderator" />
                        <asp:CheckBoxField DataField="LoggedIn" HeaderText="LoggedIn" 
                            SortExpression="LoggedIn">
                        <HeaderStyle HorizontalAlign="Center" />
                        </asp:CheckBoxField>
                    </Columns>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <RowStyle HorizontalAlign="Center" />
                </asp:GridView>  
                <asp:ObjectDataSource ID="UsersDS" runat="server" 
                    SelectMethod="searchForNewFriend" 
                    TypeName="ForumLibrary.Data.ForumWebManager">
                    <SelectParameters>
                        <asp:SessionParameter Name="username" SessionField="username" Type="String" />
                        <asp:Parameter DefaultValue="&quot;&quot;" Name="searchedUser" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>





